﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppPort;
using TiEntityObject.Notification;
using TiPort.TiEntityObjects;
using System.Web;
using TI_EntityLib.TiEntityObjects.Kladr;

namespace Controllers.ReportControllerCommands
{
    /// <summary>
    /// Вернуть строки документов
    /// </summary>
    public class MarketSizeByContracts
    {
        private class inMarketSizeByContracts
        {
            private string _contentInfo = string.Empty;
            public string ContentInfo { get { return _contentInfo + ".*"; } set { _contentInfo = value; } }
            public long iDtStart { get; set; }
            public long iDtEnd { get; set; }
            public List<string> territoryList { get; set; }
            public long iMaxPriceStart { get; set; }
            public long iMaxPriceEnd { get; set; }
            public List<string> placingWay { get; set; }
            public override string ToString()
            {
                return Helper.Json<inMarketSizeByContracts>.NewtonSerializeObject(this);
            }
        }


        private class outMarketSizeByContracts 
        {
            public string _id { get ;set; }
            public long  value { get ;set; }

            public string name { get { return _id; } }
            public long data1 { get { return value; } }            
        }

        public static string Run(ServiceCmd cmd)
        {
            inMarketSizeByContracts ip = Helper.Json<inMarketSizeByContracts>.NewtonDeserializeObject(cmd.args.ToString());
            var script = "reportMarketSizeByContracts(" + ip.ToString() + ");";
            List<outMarketSizeByContracts> lst = Helper.MongoTools.Instance.GetCollection<outMarketSizeByContracts>(script);
            string s = Helper.Json<outMarketSizeByContracts>.ListToJson(lst);
            return "{success:true, d:"+s+"}";
            
        }
    }
}
